﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Program04
{
    public class Ticket
    {
        public Ticket(double distance)
        {
            //距离大于0
            this.Distance=distance>0?distance:0;
        }
        //属性只读
        public double Distance{ get; }

        public double Price => (Distance > 0 && Distance <= 100)
            ? Distance * 1.0
            : (Distance > 101 && Distance < 200
            ? Distance * 0.95
            : (Distance > 201 && Distance < 300 ? Distance * 0.9 : Distance * 0.8));

        public void ShowTicket()
        {
            Console.WriteLine("{0}公里需要{1:C}元", Distance, Price);
        }
    }
}
